<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>zggqrf.f</title>
 <meta name="generator" content="emacs 21.3.1; htmlfontify 0.20">
<style type="text/css"><!-- 
body { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default   { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default a { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.string   { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.string a { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.comment   { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.comment a { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
 --></style>

 </head>
  <body>

<pre>
      SUBROUTINE <a name="ZGGQRF.1"></a><a href="zggqrf.f.html#ZGGQRF.1">ZGGQRF</a>( N, M, P, A, LDA, TAUA, B, LDB, TAUB, WORK,
     $                   LWORK, INFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  -- LAPACK routine (version 3.1) --
</span><span class="comment">*</span><span class="comment">     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
</span><span class="comment">*</span><span class="comment">     November 2006
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Scalar Arguments ..
</span>      INTEGER            INFO, LDA, LDB, LWORK, M, N, P
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Array Arguments ..
</span>      COMPLEX*16         A( LDA, * ), B( LDB, * ), TAUA( * ), TAUB( * ),
     $                   WORK( * )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Purpose
</span><span class="comment">*</span><span class="comment">  =======
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  <a name="ZGGQRF.19"></a><a href="zggqrf.f.html#ZGGQRF.1">ZGGQRF</a> computes a generalized QR factorization of an N-by-M matrix A
</span><span class="comment">*</span><span class="comment">  and an N-by-P matrix B:
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              A = Q*R,        B = Q*T*Z,
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  where Q is an N-by-N unitary matrix, Z is a P-by-P unitary matrix,
</span><span class="comment">*</span><span class="comment">  and R and T assume one of the forms:
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  if N &gt;= M,  R = ( R11 ) M  ,   or if N &lt; M,  R = ( R11  R12 ) N,
</span><span class="comment">*</span><span class="comment">                  (  0  ) N-M                         N   M-N
</span><span class="comment">*</span><span class="comment">                     M
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  where R11 is upper triangular, and
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  if N &lt;= P,  T = ( 0  T12 ) N,   or if N &gt; P,  T = ( T11 ) N-P,
</span><span class="comment">*</span><span class="comment">                   P-N  N                           ( T21 ) P
</span><span class="comment">*</span><span class="comment">                                                       P
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  where T12 or T21 is upper triangular.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  In particular, if B is square and nonsingular, the GQR factorization
</span><span class="comment">*</span><span class="comment">  of A and B implicitly gives the QR factorization of inv(B)*A:
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">               inv(B)*A = Z'*(inv(T)*R)
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  where inv(B) denotes the inverse of the matrix B, and Z' denotes the
</span><span class="comment">*</span><span class="comment">  conjugate transpose of matrix Z.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Arguments
</span><span class="comment">*</span><span class="comment">  =========
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  N       (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The number of rows of the matrices A and B. N &gt;= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  M       (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The number of columns of the matrix A.  M &gt;= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  P       (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The number of columns of the matrix B.  P &gt;= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  A       (input/output) COMPLEX*16 array, dimension (LDA,M)
</span><span class="comment">*</span><span class="comment">          On entry, the N-by-M matrix A.
</span><span class="comment">*</span><span class="comment">          On exit, the elements on and above the diagonal of the array
</span><span class="comment">*</span><span class="comment">          contain the min(N,M)-by-M upper trapezoidal matrix R (R is
</span><span class="comment">*</span><span class="comment">          upper triangular if N &gt;= M); the elements below the diagonal,
</span><span class="comment">*</span><span class="comment">          with the array TAUA, represent the unitary matrix Q as a
</span><span class="comment">*</span><span class="comment">          product of min(N,M) elementary reflectors (see Further
</span><span class="comment">*</span><span class="comment">          Details).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LDA     (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The leading dimension of the array A. LDA &gt;= max(1,N).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  TAUA    (output) COMPLEX*16 array, dimension (min(N,M))
</span><span class="comment">*</span><span class="comment">          The scalar factors of the elementary reflectors which
</span><span class="comment">*</span><span class="comment">          represent the unitary matrix Q (see Further Details).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  B       (input/output) COMPLEX*16 array, dimension (LDB,P)
</span><span class="comment">*</span><span class="comment">          On entry, the N-by-P matrix B.
</span><span class="comment">*</span><span class="comment">          On exit, if N &lt;= P, the upper triangle of the subarray
</span><span class="comment">*</span><span class="comment">          B(1:N,P-N+1:P) contains the N-by-N upper triangular matrix T;
</span><span class="comment">*</span><span class="comment">          if N &gt; P, the elements on and above the (N-P)-th subdiagonal
</span><span class="comment">*</span><span class="comment">          contain the N-by-P upper trapezoidal matrix T; the remaining
</span><span class="comment">*</span><span class="comment">          elements, with the array TAUB, represent the unitary
</span><span class="comment">*</span><span class="comment">          matrix Z as a product of elementary reflectors (see Further
</span><span class="comment">*</span><span class="comment">          Details).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LDB     (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The leading dimension of the array B. LDB &gt;= max(1,N).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  TAUB    (output) COMPLEX*16 array, dimension (min(N,P))
</span><span class="comment">*</span><span class="comment">          The scalar factors of the elementary reflectors which
</span><span class="comment">*</span><span class="comment">          represent the unitary matrix Z (see Further Details).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  WORK    (workspace/output) COMPLEX*16 array, dimension (MAX(1,LWORK))
</span><span class="comment">*</span><span class="comment">          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LWORK   (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The dimension of the array WORK. LWORK &gt;= max(1,N,M,P).
</span><span class="comment">*</span><span class="comment">          For optimum performance LWORK &gt;= max(N,M,P)*max(NB1,NB2,NB3),
</span><span class="comment">*</span><span class="comment">          where NB1 is the optimal blocksize for the QR factorization
</span><span class="comment">*</span><span class="comment">          of an N-by-M matrix, NB2 is the optimal blocksize for the
</span><span class="comment">*</span><span class="comment">          RQ factorization of an N-by-P matrix, and NB3 is the optimal
</span><span class="comment">*</span><span class="comment">          blocksize for a call of <a name="ZUNMQR.101"></a><a href="zunmqr.f.html#ZUNMQR.1">ZUNMQR</a>.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">          If LWORK = -1, then a workspace query is assumed; the routine
</span><span class="comment">*</span><span class="comment">          only calculates the optimal size of the WORK array, returns
</span><span class="comment">*</span><span class="comment">          this value as the first entry of the WORK array, and no error
</span><span class="comment">*</span><span class="comment">          message related to LWORK is issued by <a name="XERBLA.106"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  INFO    (output) INTEGER
</span><span class="comment">*</span><span class="comment">           = 0:  successful exit
</span><span class="comment">*</span><span class="comment">           &lt; 0:  if INFO = -i, the i-th argument had an illegal value.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Further Details
</span><span class="comment">*</span><span class="comment">  ===============
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  The matrix Q is represented as a product of elementary reflectors
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Q = H(1) H(2) . . . H(k), where k = min(n,m).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Each H(i) has the form
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     H(i) = I - taua * v * v'
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  where taua is a complex scalar, and v is a complex vector with
</span><span class="comment">*</span><span class="comment">  v(1:i-1) = 0 and v(i) = 1; v(i+1:n) is stored on exit in A(i+1:n,i),
</span><span class="comment">*</span><span class="comment">  and taua in TAUA(i).
</span><span class="comment">*</span><span class="comment">  To form Q explicitly, use LAPACK subroutine <a name="ZUNGQR.126"></a><a href="zungqr.f.html#ZUNGQR.1">ZUNGQR</a>.
</span><span class="comment">*</span><span class="comment">  To use Q to update another matrix, use LAPACK subroutine <a name="ZUNMQR.127"></a><a href="zunmqr.f.html#ZUNMQR.1">ZUNMQR</a>.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  The matrix Z is represented as a product of elementary reflectors
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Z = H(1) H(2) . . . H(k), where k = min(n,p).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Each H(i) has the form
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     H(i) = I - taub * v * v'
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  where taub is a complex scalar, and v is a complex vector with
</span><span class="comment">*</span><span class="comment">  v(p-k+i+1:p) = 0 and v(p-k+i) = 1; v(1:p-k+i-1) is stored on exit in
</span><span class="comment">*</span><span class="comment">  B(n-k+i,1:p-k+i-1), and taub in TAUB(i).
</span><span class="comment">*</span><span class="comment">  To form Z explicitly, use LAPACK subroutine <a name="ZUNGRQ.140"></a><a href="zungrq.f.html#ZUNGRQ.1">ZUNGRQ</a>.
</span><span class="comment">*</span><span class="comment">  To use Z to update another matrix, use LAPACK subroutine <a name="ZUNMRQ.141"></a><a href="zunmrq.f.html#ZUNMRQ.1">ZUNMRQ</a>.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  =====================================================================
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Local Scalars ..
</span>      LOGICAL            LQUERY
      INTEGER            LOPT, LWKOPT, NB, NB1, NB2, NB3
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Subroutines ..
</span>      EXTERNAL           <a name="XERBLA.150"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>, <a name="ZGEQRF.150"></a><a href="zgeqrf.f.html#ZGEQRF.1">ZGEQRF</a>, <a name="ZGERQF.150"></a><a href="zgerqf.f.html#ZGERQF.1">ZGERQF</a>, <a name="ZUNMQR.150"></a><a href="zunmqr.f.html#ZUNMQR.1">ZUNMQR</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Functions ..
</span>      INTEGER            <a name="ILAENV.153"></a><a href="ilaenv.f.html#ILAENV.1">ILAENV</a>
      EXTERNAL           <a name="ILAENV.154"></a><a href="ilaenv.f.html#ILAENV.1">ILAENV</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Intrinsic Functions ..
</span>      INTRINSIC          INT, MAX, MIN
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Executable Statements ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Test the input parameters
</span><span class="comment">*</span><span class="comment">
</span>      INFO = 0
      NB1 = <a name="ILAENV.164"></a><a href="ilaenv.f.html#ILAENV.1">ILAENV</a>( 1, <span class="string">'<a name="ZGEQRF.164"></a><a href="zgeqrf.f.html#ZGEQRF.1">ZGEQRF</a>'</span>, <span class="string">' '</span>, N, M, -1, -1 )
      NB2 = <a name="ILAENV.165"></a><a href="ilaenv.f.html#ILAENV.1">ILAENV</a>( 1, <span class="string">'<a name="ZGERQF.165"></a><a href="zgerqf.f.html#ZGERQF.1">ZGERQF</a>'</span>, <span class="string">' '</span>, N, P, -1, -1 )
      NB3 = <a name="ILAENV.166"></a><a href="ilaenv.f.html#ILAENV.1">ILAENV</a>( 1, <span class="string">'<a name="ZUNMQR.166"></a><a href="zunmqr.f.html#ZUNMQR.1">ZUNMQR</a>'</span>, <span class="string">' '</span>, N, M, P, -1 )
      NB = MAX( NB1, NB2, NB3 )
      LWKOPT = MAX( N, M, P )*NB
      WORK( 1 ) = LWKOPT
      LQUERY = ( LWORK.EQ.-1 )
      IF( N.LT.0 ) THEN
         INFO = -1
      ELSE IF( M.LT.0 ) THEN
         INFO = -2
      ELSE IF( P.LT.0 ) THEN
         INFO = -3
      ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
         INFO = -5
      ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
         INFO = -8
      ELSE IF( LWORK.LT.MAX( 1, N, M, P ) .AND. .NOT.LQUERY ) THEN
         INFO = -11
      END IF
      IF( INFO.NE.0 ) THEN
         CALL <a name="XERBLA.185"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="ZGGQRF.185"></a><a href="zggqrf.f.html#ZGGQRF.1">ZGGQRF</a>'</span>, -INFO )
         RETURN
      ELSE IF( LQUERY ) THEN
         RETURN
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     QR factorization of N-by-M matrix A: A = Q*R
</span><span class="comment">*</span><span class="comment">
</span>      CALL <a name="ZGEQRF.193"></a><a href="zgeqrf.f.html#ZGEQRF.1">ZGEQRF</a>( N, M, A, LDA, TAUA, WORK, LWORK, INFO )
      LOPT = WORK( 1 )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Update B := Q'*B.
</span><span class="comment">*</span><span class="comment">
</span>      CALL <a name="ZUNMQR.198"></a><a href="zunmqr.f.html#ZUNMQR.1">ZUNMQR</a>( <span class="string">'Left'</span>, <span class="string">'Conjugate Transpose'</span>, N, P, MIN( N, M ), A,
     $             LDA, TAUA, B, LDB, WORK, LWORK, INFO )
      LOPT = MAX( LOPT, INT( WORK( 1 ) ) )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     RQ factorization of N-by-P matrix B: B = T*Z.
</span><span class="comment">*</span><span class="comment">
</span>      CALL <a name="ZGERQF.204"></a><a href="zgerqf.f.html#ZGERQF.1">ZGERQF</a>( N, P, B, LDB, TAUB, WORK, LWORK, INFO )
      WORK( 1 ) = MAX( LOPT, INT( WORK( 1 ) ) )
<span class="comment">*</span><span class="comment">
</span>      RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     End of <a name="ZGGQRF.209"></a><a href="zggqrf.f.html#ZGGQRF.1">ZGGQRF</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>
